//
//  FeedBackViewController.swift
//  daily_count
//
//  Created by 段帅 on 2018/8/21.
//  Copyright © 2018年 Sooc. All rights reserved.
//

import UIKit

class FeedBackViewController: UIViewController,UITextViewDelegate {
    @IBOutlet weak var title_label: UITextField!
    
    @IBOutlet weak var content_label: UITextView!
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "意见反馈";
        content_label.delegate = self as UITextViewDelegate;

        // Do any additional setup after loading the view.
    }
    
     func textViewDidBeginEditing(_ textView: UITextView) {
        if content_label.text == "在此输入反馈内容！~" {
            content_label.text = nil;
        }
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    @IBAction func send(_ sender: Any) {
        print(content_label.text!,title_label.text!);
        
        if content_label.text.count == 0||title_label.text?.count==0 {
            DSToolManager.alertFaild(message: "标题或者内容不能为空");
        }
        
        
        DSToolManager.postWithToken(URLString: severseUrl+api_feedback, parameters: ["title":title_label.text as AnyObject,"content":content_label.text as AnyObject]) { (data, isSucess) in
            if (isSucess) {
                DSToolManager.alertSucess(message: "反馈成功");
                self.content_label.text = nil;
                self.title_label.text = nil;
            }else {
                DSToolManager.alertFaild(message: data!["statusCode"] as! String);
            }
        }
        
        
        
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
